import os
import zipfile

# 输出文件名
output_zip = "output.zip"

# 排除的文件名或目录名（只匹配名称，不匹配路径）
exclude_names = {
    ".git",
    "output.zip",
    "node_modules",
    "build.py",
    "package-lock.json",
    "scripts"
}

def should_exclude(name):
    return name in exclude_names

def zipdir(base_dir, ziph):
    for root, dirs, files in os.walk(base_dir):
        # 排除目录
        dirs[:] = [d for d in dirs if not should_exclude(d)]
        for file in files:
            if should_exclude(file):
                continue
            full_path = os.path.join(root, file)
            rel_path = os.path.relpath(full_path, base_dir)
            ziph.write(full_path, arcname=rel_path)

if __name__ == "__main__":
    with zipfile.ZipFile(output_zip, 'w', zipfile.ZIP_DEFLATED) as zipf:
        zipdir(".", zipf)
    print(f"✅ 打包完成: {output_zip}")
